﻿<!--
   Copyright (c) 2011, Microsoft Corporation
  
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
  
	   http://www.apache.org/licenses/LICENSE-2.0
  
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<phone:PhoneApplicationPage
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:v="clr-namespace:Microsoft.Samples.ServiceBus.WindowsPhoneChat" xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="phoneApplicationPage" 
	x:Class="Microsoft.Samples.ServiceBus.WindowsPhoneChat.MainPage"
	FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	SupportedOrientations="Portrait"
	mc:Ignorable="d" Orientation="Portrait"
	d:DesignHeight="696" d:DesignWidth="480"
	shell:SystemTray.IsVisible="True">

	<!--LayoutRoot is the root grid where all page content is placed-->
	<Grid x:Name="LayoutRoot" Background="Transparent" Visibility="Collapsed" RenderTransformOrigin="0.5,0.5">
		<Grid.RenderTransform>
			<CompositeTransform/>
		</Grid.RenderTransform>
		<Grid.Projection>
			<PlaneProjection CenterOfRotationY="0"/>
		</Grid.Projection>
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="ViewStates">
				<VisualStateGroup.Transitions>
					<VisualTransition GeneratedDuration="0"/>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="Login"/>
				<VisualState x:Name="Chat">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loginControl">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="chatTopicListControl">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
			<VisualStateGroup x:Name="DialogStates">
				<VisualStateGroup.Transitions>
					<VisualTransition GeneratedDuration="0:0:0.5">
						<VisualTransition.GeneratedEasingFunction>
							<BackEase EasingMode="EaseOut" Amplitude="0.3"/>
						</VisualTransition.GeneratedEasingFunction>
					</VisualTransition>
					<VisualTransition From="AddTopic" GeneratedDuration="0:0:0.5">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="addTopicDialog">
								<DiscreteObjectKeyFrame KeyTime="0">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
								<DiscreteObjectKeyFrame KeyTime="0:0:0.5">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Collapsed</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="addTopicDialog">
								<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="600">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseIn" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="addTopicDialog">
								<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-50">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseIn" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
					</VisualTransition>
					<VisualTransition GeneratedDuration="0:0:0.5" To="AddTopic">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="addTopicDialog">
								<DiscreteObjectKeyFrame KeyTime="0">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
								<DiscreteObjectKeyFrame KeyTime="0:0:0.5">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="addTopicDialog">
								<EasingDoubleKeyFrame KeyTime="0" Value="600"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseOut" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="addTopicDialog">
								<EasingDoubleKeyFrame KeyTime="0" Value="-50"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseOut" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
					</VisualTransition>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="AddTopic">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="addTopicDialog">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="NoDialog"/>
			</VisualStateGroup>
			<VisualStateGroup x:Name="VisibilityStates">
				<VisualStateGroup.Transitions>
					<VisualTransition GeneratedDuration="0" To="Visible">
						<Storyboard>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="LayoutRoot">
								<EasingDoubleKeyFrame KeyTime="0" Value="-240"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseOut" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LayoutRoot">
								<DiscreteObjectKeyFrame KeyTime="0">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
								<DiscreteObjectKeyFrame KeyTime="0:0:0.7">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="LayoutRoot">
								<EasingDoubleKeyFrame KeyTime="0" Value="90"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseOut" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
					</VisualTransition>
					<VisualTransition To="NotVisible" GeneratedDuration="0">
						<Storyboard>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="LayoutRoot">
								<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="-240">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseIn" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="LayoutRoot">
								<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
								<EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="90">
									<EasingDoubleKeyFrame.EasingFunction>
										<BackEase EasingMode="EaseIn" Amplitude="0.3"/>
									</EasingDoubleKeyFrame.EasingFunction>
								</EasingDoubleKeyFrame>
							</DoubleAnimationUsingKeyFrames>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LayoutRoot">
								<DiscreteObjectKeyFrame KeyTime="0">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Visible</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
								<DiscreteObjectKeyFrame KeyTime="0:0:0.7">
									<DiscreteObjectKeyFrame.Value>
										<Visibility>Collapsed</Visibility>
									</DiscreteObjectKeyFrame.Value>
								</DiscreteObjectKeyFrame>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualTransition>
				</VisualStateGroup.Transitions>
				<VisualState x:Name="Visible">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LayoutRoot">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="NotVisible">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LayoutRoot">
							<DiscreteObjectKeyFrame KeyTime="0">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>	
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		
		<v:LoginControl x:Name="loginControl" DataContext="{Binding LoginControlViewModel}" Margin="0" Grid.RowSpan="2"/>
		<v:ChatTopicListControl x:Name="chatTopicListControl" DataContext="{Binding ChatTopicListControlViewModel}" Margin="12,0,0,0" Grid.Row="1" Visibility="Collapsed"/>
		<v:AddTopicDialog x:Name="addTopicDialog" Margin="0" d:LayoutOverrides="Width, Height" Grid.RowSpan="2" Background="Black" RenderTransformOrigin="0.5,0.5" Visibility="Collapsed">
			<v:AddTopicDialog.Projection>
				<PlaneProjection/>
			</v:AddTopicDialog.Projection>
			<v:AddTopicDialog.RenderTransform>
				<CompositeTransform/>
			</v:AddTopicDialog.RenderTransform>
		</v:AddTopicDialog>
	</Grid>
 </phone:PhoneApplicationPage>
